package stream;

import jdk.internal.reflect.ConstructorAccessor;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.*;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
import java.util.Locale;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class StreamTest {


    public static void main(String[] args) throws CloneNotSupportedException, IOException {

//        System.out.println("\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020\u0020\n" +
//            "\u0063\u006c\u0061\u0073\u0073\u0020\u0055\u0067\u006c\u0079\n" +
//            "\u007b\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020\n" +
//            "\u0020\u0020\u0020\u0020\u0073\u0074\u0061\u0074\u0069\u0063\n" +
//            "\u0076\u006f\u0069\u0064\u0020\u006d\u0061\u0069\u006e\u0028\n" +
//            "\u0053\u0074\u0072\u0069\u006e\u0067\u005b\u005d\u0020\u0020\n" +
//            "\u0020\u0020\u0020\u0020\u0061\u0072\u0067\u0073\u0029\u007b\n" +
//            "\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\n" +
//            "\u002e\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028\u0020\n" +
//            "\u0022\u0048\u0065\u006c\u006c\u006f\u0020\u0077\u0022\u002b\n" +
//            "\u0022\u006f\u0072\u006c\u0064\u0022\u0029\u003b\u007d\u007d");
        /*util
         */

//        Stream.generate(StreamTest::a).limit(10).parallel()
//        // .forEach(x->{});
//        .forEach(System.out::println);
//        //.reduce(0,(x,y)->x+1,(x,y)->x+y);
//        C c = new C();
//        C c1 = c.clone();
//        System.out.println(c1);
//
//        ObjectOutputStream  os = new ObjectOutputStream(new ByteArrayOutputStream());
//        os.writeObject(new A());
//        String aa = "dfasfdasf\23";
//        aa = aa + "";
//        boolean matches = aa.matches("\p{Lower}{1,5}");
//        System.out.println();
        System.out.println(new Date());
        long l = Clock.systemUTC().millis() - Instant.now().toEpochMilli();
        System.out.println(l);
        LocalDate date = LocalDate.now();
        date.with(TemporalAdjusters.lastDayOfMonth());
    }

    public static int a() {
        int i = new Random().nextInt();
        assert Math.ceil(1) == 1 : null;
        System.out.println("===============================" + i + "====////////" + Thread.currentThread());
        return i;

    }

    public static class A implements Serializable {
        B b = new B(this);
    }

    public static class B implements Serializable {
        A a;

        public B(A a) {
            this.a = a;
        }
    }


    public static String reverse(String originStr) {
        char[] chars = originStr.toCharArray();
        for (int i = 0; i < chars.length / 2; i++) {
            int j = chars.length - 1 - i;
            char ci = chars[i];
            char cj = chars[j];
            chars[i] = cj;
            chars[j] = ci;
        }


        return new String(chars);
    }


}

class Annoyance extends Exception {
}

class Sneeze extends Annoyance {
}

class Human {

    public static void main(String[] args) throws Exception {
        try {
            try {
                throw new Sneeze();
            } catch (Annoyance a) {
                System.out.println("Caught Annoyance");
                throw a;
            }
        } catch (Sneeze s) {
            System.out.println("Caught Sneeze");
        } finally {
            System.out.println("Hello World!");
        }
    }
}